<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var num = [20,12,40,99,32,47];
        var a = 0;
        for (var i = 0; i < num.length -1; i++){
            for (var j = 0; j < num.length -1; j ++){
                if(num[j] > num[j+1]){
                a = num[j+1]
                num[j+1] = num[j]
                num[j] = a
            }
            
            }
        }
        document.write(num)
    </script>
</body>
</html>